import {storeKeys} from "@/basic/stores/state";
import {mapState, mapGetters} from "vuex";
// 使用方法为：如果要修改vuex的state中的user.name变量为"史诗" => this.vuex('user.name', '史诗')
export default {
	data() {
		return {};
	},
	created() {
		// 将vuex方法挂在到this中
		this.vuex = (name, value) => {
			this.$store.commit("storeCommit", {name, value});
		};
		this.resetVuex = () => {
			this.$store.commit("storeCommit", {name: "token"});
		};
		this.switchTab = (tabName) => {
			if (tabName !== this.$route.path) {
				this.vuex("activeTabValue", tabName);
				this.$router.push({path: tabName});
			}
		};
	},
	// 将vuex的state中的所有变量，解构到全局混入的mixin中
	computed: {
		...mapState(storeKeys),
		...mapGetters(storeKeys)
	}
};
